﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Input;
using System.Data;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;
using GalaSoft.MvvmLight.Command;
using GoldDigger.AppServices;
using GoldDigger.Models;
using GoldDigger.Data;

namespace GoldDigger.ViewModels
{
    public class FeatureSelectionResultsViewModel : ViewModelBase
    {
        private ICommand _associationRuleCommand;
        private ICommand _backToFeatureSelectionCommand;
        private ObservableCollection<AttributeModel> _selectedFeatures;
        private MainService _app;

        public FeatureSelectionResultsViewModel(MainService ms)
        {
            _app = ms;
            _selectedFeatures = new ObservableCollection<AttributeModel>(_app.AppData.ReducedAttributeList);
        }

        public int FeatureSelectedCount
        {
            get
            {
                return _app.AppData.ReducedFeatureDT.Columns.Count-2;
            }
        }

        public ObservableCollection<AttributeModel> SelectedFeatures
        {
            get
            {
                return _selectedFeatures;
            }
        }

        public ICommand AssociationRuleCommand
        {
            get
            {
                return _associationRuleCommand ?? (_associationRuleCommand = new RelayCommand(GoToAssociationRuleView));
            }
        }

        public ICommand BackToFeatureSelectionCommand
        {
            get
            {
                return _backToFeatureSelectionCommand ?? (_backToFeatureSelectionCommand = new RelayCommand(BackToFeatureSelection));
            }
        }

        public void BackToFeatureSelection()
        {
            _app.AppData.ReducedFeatureDT = new DataTable();
            _app.AppData.AttributeSymmetricalUncertainty = new List<SuValueModel>();  
            _app.AppData.ReducedAttributeList = new List<AttributeModel>();
            Messenger.Default.Send(new NotificationMessage<ViewModelBase>(new FeatureSelectionViewModel(_app), "ChangeVM"));
        }

        public void GoToAssociationRuleView()
        {
            _app.CommandCallSource = CallSourceEnum.CallSource.Processed;
            Messenger.Default.Send(new NotificationMessage<ViewModelBase>(new AssociationRuleViewModel(_app), "ChangeVM"));
        }
    }
}
 